<template>
	<view>
		<u-navbar title="我的合同" @leftClick="leftClick" :autoback="true"></u-navbar>
		<view class="content" v-for="item in contractArrs" :key="item.id">
			<contractDetail :info="item"></contractDetail>
		</view>
		<!-- -->
		<view  class="more" @click="getInitData('more')" v-if="contractArrs.length >= 6" >
			加载更多
		</view>
		<u-loading-icon v-if="isLoading" mode="circle" text="加载中..."></u-loading-icon>
		<u-empty v-if="!contractArrs.length" class="empty-data">
		</u-empty>
	</view>
</template>

<script>
	import {getContract} from '@/api/index.js'
	import contractDetail from '../../components/contractDetails.vue'
	export default {
		components:{contractDetail},
		data() {
			return {
				isLoading:true,
				indexSign:1,
				contractArrs:[]
			};
		},
		onLoad(option) {
			this.getInitData();
			console.log(!this.$userInfo()?.id)
			if(!this.$userInfo()?.id) {
				this.isLoading = false;
				
			}
		},
		
		created() {
		
		},
		mounted() {
			
		},
		methods:{
			leftClick(){
				if (getCurrentPages().length > 1) {
					uni.navigateBack();
				} else {
					uni.switchTab({
						url: '../../pages/index/index'
					})
				}
			},
			getInitData(type){
				if(type) {
					this.indexSign += 1;
				}
				getContract({pageSize:this.indexSign*10,pageNo:1}).then(res => {
					if(res.code === 200) {
						this.contractArrs = res.data.list;
						this.isLoading = false;
					}else {
						this.isLoading = false;
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.more {
	width: 100%;
	height: 88rpx;
	line-height: 80rpx;
	background: #fff;
	align-items: center;
	text-align: center;
	font-size: 32rpx;
}

.content {
	border-bottom: 16rpx solid #f6f4f8;
}
</style>
